

<?php

function LogInS($UName,$Password)
  {
 	
include("db_util.php");
$connection=DbConnect();
if(!$connection)
		echo "DisConnected!<br>";
		
		
		
		
$query='SELECT * FROM Student where email=\'' . $UName . '\' and password=\'' . $Password . '\''; 

$statement = oci_parse($connection, $query);

	$res=oci_execute($statement);
	
	$row = oci_fetch_array($statement, OCI_ASSOC+OCI_RETURN_NULLS);
	
//$statement=QueryExecution($connection,$query);
if($row)
		 {
		
		 session_start(); 
    $_SESSION["StuID"] = OCIResult( $statement, 'SID' );
	//echo $_SESSION["StuID"];
    $_SESSION["login"] = true;
	date_default_timezone_set('EST');  
	$query='Update student set last_login_time=\'' . date('d-M-y') . '\' where sid=' . OCIResult( $statement, 'SID' ); 
//echo $query;
$statementlogin = oci_parse($connection, $query);

	oci_execute($statementlogin);
	oci_free_statement($statementlogin);
	
 DbConnectionClose($connection,  $statement);
		 header('Location: Personal.php') ;
		 }
		 else {
		 echo "You typed the wrong username or password!<br>";
		 DbConnectionClose($connection,  $statement);
		 return false;
		 }
		


		
		return true;

  }
  
  function LogInA($UName,$Password)
  {
 	include("db_util.php");

$connection=DbConnect();
if(!$connection)
		echo "DisConnected!<br>";
		
$query='SELECT * FROM Administrator where email=\'' . $UName . '\' and password=\'' . $Password . '\''; 

$statement = oci_parse($connection, $query);

	$res=oci_execute($statement);
	
	$row = oci_fetch_array($statement, OCI_ASSOC+OCI_RETURN_NULLS);
	
//$statement=QueryExecution($connection,$query);
if($row)
		 {
		
		 session_start(); 
    $_SESSION["AdminID"] = OCIResult( $statement, 'AID' );
	
    $_SESSION["login"] = true;  
 DbConnectionClose($connection,  $statement);
		 header('Location: AdminHome.php') ;
		 }
		 else {
		 echo "You typed the wrong username or password!<br>";
		 DbConnectionClose($connection,  $statement);
		 return false;
		 }
		


		
		return true;

  }
 //LogIn($_POST["uname"],$_POST["pwd"]); 
 
 

?>

